//
//  registeredViewController.m
//  OurTourism
//
//  Created by dllo on 15/12/4.
//  Copyright © 2015年 Devil_Coming. All rights reserved.
//

#import "registeredViewController.h"
#import "Header.h"
#import <BmobSDK/Bmob.h>
@interface registeredViewController ()
@property (weak, nonatomic) IBOutlet UITextField *account;

@property (weak, nonatomic) IBOutlet UITextField *password;

@property (weak, nonatomic) IBOutlet UITextField *passwordAgain;

@end

@implementation registeredViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}
- (IBAction)done:(UIButton *)sender {
 
    BmobQuery   *bquery = [BmobQuery queryWithClassName:@"Mzzz"];
    
    
    [bquery getObjectInBackgroundWithId:self.account.text block:^(BmobObject *object,NSError *error){
        if (error){
            //进行错误处理
            NSLog(@"错误");
        }else{
            //表里有id为0c6db13c的数据
            if (object) {
                //得到playerName和cheatMode
                NSString *name = [object objectForKey:@"name"];
//                BOOL cheatMode = [[object objectForKey:@"cheatMode"] boolValue];
                NSLog(@"%@-",name);
            }
        }
    }];
    
    
    
    
    
    
//    BmobQuery   *bquery = [BmobQuery queryWithClassName:@"Mzzz"];
//    
//  [bquery findObjectsInBackgroundWithBlock:^(NSArray *array, NSError *error) {
//    for (int i= 0; i < array.count; i++) {
//        if(self.account.text == [array[i] objectForKey:@"name"])
//        {
//            NSLog(@"账号存在");
//        }else{
//            
//            if(self.account.text == nil)
//            {
//            BmobObject *gameScore = [BmobObject objectWithClassName:@"Mzzz"];
//            [gameScore setObject:self.account.text forKey:@"account"];
//            [gameScore setObject:self.password.text forKey:@"password"];
//            [gameScore saveInBackgroundWithResultBlock:^(BOOL isSuccessful, NSError *error) {
//                //进行操作
//            }];
//            NSLog(@"注册成功");
//            }
//            else
//            {
//                NSLog(@"密码账号不能为空");
//            }
//        }
//    }
//}];
//



    
    
    
    
    [self.navigationController popToRootViewControllerAnimated:YES];
    
}
- (IBAction)back:(UIButton *)sender {
    
    [self.navigationController popViewControllerAnimated:YES];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
